﻿using System;
using HslCommunication.Algorithms.ConnectPool;

namespace HslCommunication.MQTT
{
	/// <summary>
	/// 关于MqttSyncClient实现的接口<see cref="T:HslCommunication.Algorithms.ConnectPool.IConnector" />，从而实现了数据连接池的操作信息
	/// </summary>
	// Token: 0x020000BC RID: 188
	public class IMqttSyncConnector : IConnector
	{
		/// <summary>
		/// 根据连接的MQTT参数，实例化一个默认的对象<br />
		/// According to the connected MQTT parameters, instantiate a default object
		/// </summary>
		/// <param name="options">连接的参数信息</param>
		// Token: 0x06000E02 RID: 3586 RVA: 0x00053317 File Offset: 0x00051517
		public IMqttSyncConnector(MqttConnectionOptions options)
		{
			this.connectionOptions = options;
			this.SyncClient = new MqttSyncClient(options);
		}

		/// <summary>
		/// 实例化一个默认的对象<br />
		/// Instantiate a default object
		/// </summary>
		// Token: 0x06000E03 RID: 3587 RVA: 0x00015527 File Offset: 0x00013727
		public IMqttSyncConnector()
		{
		}

		/// <inheritdoc cref="P:HslCommunication.Algorithms.ConnectPool.IConnector.IsConnectUsing" />
		// Token: 0x17000207 RID: 519
		// (get) Token: 0x06000E04 RID: 3588 RVA: 0x00053335 File Offset: 0x00051535
		// (set) Token: 0x06000E05 RID: 3589 RVA: 0x0005333D File Offset: 0x0005153D
		public bool IsConnectUsing { get; set; }

		/// <inheritdoc cref="P:HslCommunication.Algorithms.ConnectPool.IConnector.GuidToken" />
		// Token: 0x17000208 RID: 520
		// (get) Token: 0x06000E06 RID: 3590 RVA: 0x00053346 File Offset: 0x00051546
		// (set) Token: 0x06000E07 RID: 3591 RVA: 0x0005334E File Offset: 0x0005154E
		public string GuidToken { get; set; }

		/// <inheritdoc cref="P:HslCommunication.Algorithms.ConnectPool.IConnector.LastUseTime" />
		// Token: 0x17000209 RID: 521
		// (get) Token: 0x06000E08 RID: 3592 RVA: 0x00053357 File Offset: 0x00051557
		// (set) Token: 0x06000E09 RID: 3593 RVA: 0x0005335F File Offset: 0x0005155F
		public DateTime LastUseTime { get; set; }

		/// <summary>
		/// MQTT的连接对象
		/// </summary>
		// Token: 0x1700020A RID: 522
		// (get) Token: 0x06000E0A RID: 3594 RVA: 0x00053368 File Offset: 0x00051568
		// (set) Token: 0x06000E0B RID: 3595 RVA: 0x00053370 File Offset: 0x00051570
		public MqttSyncClient SyncClient { get; set; }

		/// <inheritdoc cref="M:HslCommunication.Algorithms.ConnectPool.IConnector.Close" />
		// Token: 0x06000E0C RID: 3596 RVA: 0x00053379 File Offset: 0x00051579
		public void Close()
		{
			MqttSyncClient syncClient = this.SyncClient;
			if (syncClient != null)
			{
				syncClient.ConnectClose();
			}
		}

		/// <inheritdoc cref="M:HslCommunication.Algorithms.ConnectPool.IConnector.Open" />
		// Token: 0x06000E0D RID: 3597 RVA: 0x0005338E File Offset: 0x0005158E
		public void Open()
		{
			MqttSyncClient syncClient = this.SyncClient;
			if (syncClient != null)
			{
				syncClient.SetPersistentConnection();
			}
		}

		// Token: 0x040003B2 RID: 946
		private MqttConnectionOptions connectionOptions;
	}
}
